#include "stdafx.h"
#ifdef LIT_OGRE_SUPPORT
#include "LitMovableDatas.h"
#include <LitExceptions.h>

namespace Lit
{
	MovableDatas::MovableDatas( const String &movable_name_ ) : movable_name( movable_name ){}
	MovableDatas::MovableDatas( const MovableDatas& rk ) : movable_name( rk.movable_name ), map(rk.map){ }
	MovableDatas::~MovableDatas( ){}

	bool MovableDatas::hasData( const String &name ) const{ return (map.find(name) != map.end()); }

	void MovableDatas::addData( const String &name, Any any )
	{
		if( hasData( name)  ) throw Lit::ItemDuplicate( propertyFullName(name), "MovableDatas("+movable_name+")", EXC_LOC );
		map[name] = any;
	}

	String MovableDatas::propertyFullName( const String &name ) const
	{
		return "Movable("+parentName()+")."+(name.empty()?"<unknown>":name)+"";
	}

	size_t MovableDatas::size() const{ return map.size(); }
	bool MovableDatas::empty() const{ return map.empty(); }
	void MovableDatas::clear(){ map.clear(); }

	String MovableDatas::parentName() const{ return movable_name; }
		
	const MovableDatas::Map & MovableDatas::datas() const{ return map; }
	MovableDatas::Map& MovableDatas::datas(){ return map; }

	MovableDatas::Itor MovableDatas::begin() { return map.begin(); }
	MovableDatas::ConstItor MovableDatas::begin() const{ return map.begin(); }

	MovableDatas::Itor MovableDatas::end() { return map.end(); }
	MovableDatas::ConstItor MovableDatas::end() const{ return map.end(); }
};

#endif